"""
# -*- coding: utf-8 -*-
# @Time    : 2023/5/24 20:13
# @Author  : 王摇摆
# @FileName: Ball_Tree.py
# @Software: PyCharm
# @Blog    ：https://blog.csdn.net/weixin_44943389?type=blog
"""
import time
import numpy as np
from sklearn.neighbors import BallTree

from ANN.Data import trains, test, k

start = time.time()
tree = BallTree(trains)
cost = time.time() - start
print("Ball Tree Build: ", cost)

start = time.time()
distances, nearests = tree.query(np.array([test]), k)
cost = time.time() - start
print('===============================================')
print("Ball Tree Search: ", cost)
print("Indexes: ", nearests[0])
print("Distances: ", distances[0])
